package zhongbo.java.air.ingestion.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import zhongbo.java.air.ingestion.listener.RedisFlightPathListener;


/**
 * @author WeiJin
 * @version 1.0
 * @since 2025/4/2 9:13
 */
@Configuration
@Slf4j
public class RedisListenerConfig {

    /**
     * 接收频道
     */
    public static final String FLIGHT_PATH_CHANEL = "flight_path_chanel";

    /**
     * 配置redis listenerContainer监听容器，添加logChanelListener 监听器到容器里，同事说指定频道
     *
     * @param listenerContainer       注入listenerContainer （在common模块配置了bean）
     * @param redisFlightPathListener redis航迹频道监听器
     */
    @Autowired
    public void configListener(RedisMessageListenerContainer listenerContainer,
                               RedisFlightPathListener redisFlightPathListener
    ) {
        log.info("配置redis监听器");
        Topic topic = new PatternTopic(FLIGHT_PATH_CHANEL);
        listenerContainer.addMessageListener(redisFlightPathListener, topic);

    }
}
